package b.p.b;

import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.view.accessibility.AccessibilityEvent;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.RecyclerView.m;
import androidx.recyclerview.widget.RecyclerView.s;
import androidx.recyclerview.widget.RecyclerView.w;
import b.i.k.y.b;
import b.i.k.y.c;
import java.util.Map;
import java.util.WeakHashMap;

/* compiled from: RecyclerViewAccessibilityDelegate */
public class c0 extends b.i.k.a {
    public final RecyclerView d;
    public final a e;

    /* compiled from: RecyclerViewAccessibilityDelegate */
    public static class a extends b.i.k.a {
        public final c0 d;
        public Map<View, b.i.k.a> e = new WeakHashMap();

        public a(c0 c0Var) {
            this.d = c0Var;
        }

        public boolean a(View view, AccessibilityEvent accessibilityEvent) {
            b.i.k.a aVar = (b.i.k.a) this.e.get(view);
            if (aVar != null) {
                return aVar.a(view, accessibilityEvent);
            }
            return this.a.dispatchPopulateAccessibilityEvent(view, accessibilityEvent);
        }

        public c b(View view) {
            b.i.k.a aVar = (b.i.k.a) this.e.get(view);
            if (aVar != null) {
                return aVar.b(view);
            }
            return super.b(view);
        }

        public void c(View view, AccessibilityEvent accessibilityEvent) {
            b.i.k.a aVar = (b.i.k.a) this.e.get(view);
            if (aVar != null) {
                aVar.c(view, accessibilityEvent);
            } else {
                this.a.onInitializeAccessibilityEvent(view, accessibilityEvent);
            }
        }

        public void d(View view, b bVar) {
            if (this.d.j() || this.d.d.getLayoutManager() == null) {
                this.a.onInitializeAccessibilityNodeInfo(view, bVar.a);
                return;
            }
            this.d.d.getLayoutManager().m0(view, bVar);
            b.i.k.a aVar = (b.i.k.a) this.e.get(view);
            if (aVar != null) {
                aVar.d(view, bVar);
            } else {
                this.a.onInitializeAccessibilityNodeInfo(view, bVar.a);
            }
        }

        public void e(View view, AccessibilityEvent accessibilityEvent) {
            b.i.k.a aVar = (b.i.k.a) this.e.get(view);
            if (aVar != null) {
                aVar.e(view, accessibilityEvent);
            } else {
                this.a.onPopulateAccessibilityEvent(view, accessibilityEvent);
            }
        }

        public boolean f(ViewGroup viewGroup, View view, AccessibilityEvent accessibilityEvent) {
            b.i.k.a aVar = (b.i.k.a) this.e.get(viewGroup);
            if (aVar != null) {
                return aVar.f(viewGroup, view, accessibilityEvent);
            }
            return this.a.onRequestSendAccessibilityEvent(viewGroup, view, accessibilityEvent);
        }

        public boolean g(View view, int i, Bundle bundle) {
            if (this.d.j() || this.d.d.getLayoutManager() == null) {
                return super.g(view, i, bundle);
            }
            b.i.k.a aVar = (b.i.k.a) this.e.get(view);
            if (aVar != null) {
                if (aVar.g(view, i, bundle)) {
                    return true;
                }
            } else if (super.g(view, i, bundle)) {
                return true;
            }
            m layoutManager = this.d.d.getLayoutManager();
            s sVar = layoutManager.b.b;
            return layoutManager.E0();
        }

        public void h(View view, int i) {
            b.i.k.a aVar = (b.i.k.a) this.e.get(view);
            if (aVar != null) {
                aVar.h(view, i);
            } else {
                this.a.sendAccessibilityEvent(view, i);
            }
        }

        public void i(View view, AccessibilityEvent accessibilityEvent) {
            b.i.k.a aVar = (b.i.k.a) this.e.get(view);
            if (aVar != null) {
                aVar.i(view, accessibilityEvent);
            } else {
                this.a.sendAccessibilityEventUnchecked(view, accessibilityEvent);
            }
        }
    }

    public c0(RecyclerView recyclerView) {
        this.d = recyclerView;
        a aVar = this.e;
        if (aVar != null) {
            this.e = aVar;
        } else {
            this.e = new a(this);
        }
    }

    public void c(View view, AccessibilityEvent accessibilityEvent) {
        this.a.onInitializeAccessibilityEvent(view, accessibilityEvent);
        if ((view instanceof RecyclerView) && !j()) {
            RecyclerView recyclerView = (RecyclerView) view;
            if (recyclerView.getLayoutManager() != null) {
                recyclerView.getLayoutManager().k0(accessibilityEvent);
            }
        }
    }

    public void d(View view, b bVar) {
        this.a.onInitializeAccessibilityNodeInfo(view, bVar.a);
        if (!j() && this.d.getLayoutManager() != null) {
            m layoutManager = this.d.getLayoutManager();
            RecyclerView recyclerView = layoutManager.b;
            s sVar = recyclerView.b;
            w wVar = recyclerView.i0;
            if (recyclerView.canScrollVertically(-1) || layoutManager.b.canScrollHorizontally(-1)) {
                bVar.a.addAction(8192);
                bVar.a.setScrollable(true);
            }
            if (layoutManager.b.canScrollVertically(1) || layoutManager.b.canScrollHorizontally(1)) {
                bVar.a.addAction(4096);
                bVar.a.setScrollable(true);
            }
            bVar.i(b.b.a(layoutManager.U(sVar, wVar), layoutManager.C(sVar, wVar), layoutManager.Y(), layoutManager.V()));
        }
    }

    public boolean g(View view, int i, Bundle bundle) {
        if (super.g(view, i, bundle)) {
            return true;
        }
        if (j() || this.d.getLayoutManager() == null) {
            return false;
        }
        m layoutManager = this.d.getLayoutManager();
        s sVar = layoutManager.b.b;
        return layoutManager.D0(i);
    }

    public boolean j() {
        return this.d.N();
    }
}
